import 'dart:async';

import 'package:flutter/services.dart';

class FlutterPluginPrint {
  static const MethodChannel _channel = MethodChannel('flutter_plugin_print');

  static Future<String?> get platformVersion async {
    final String? version = await _channel.invokeMethod('getPlatformVersion');
    return version;
  }

  static Future<void> demo() async {
    await _channel.invokeMethod('DEMO');
  }

  static Future<void> printText(String text) async {
    Map<String, dynamic> arguments = <String, dynamic>{"text": '$text\n'};
    await _channel.invokeMethod('PRINT_TEXT', arguments);
  }

  static Future<void> halfCut() async {
    await _channel.invokeMethod('HALF_CUT');
  }

  static Future<void> allCut() async {
    await _channel.invokeMethod('ALL_CUT');
  }

  static Future<void> setFont(int mCharacterType, int mWidth, int mHeight, int mBold, int mUnderline) async {
    Map<String, dynamic> arguments = <String, dynamic>{};
    arguments['mCharacterType'] = mCharacterType;
    arguments['mWidth'] = mWidth;
    arguments['mHeight'] = mHeight;
    arguments['mBold'] = mBold;
    arguments['mUnderline'] = mUnderline;
    await _channel.invokeMethod('SET_FONT', arguments);
  }

  static Future<void> alignLeft() async {
    await _channel.invokeMethod('ALIGN_LEFT');
  }

  static Future<void> alignRight() async {
    await _channel.invokeMethod('ALIGN_RIGHT');
  }

  static Future<void> alignCenter() async {
    await _channel.invokeMethod('ALIGN_CENTER');
  }

  static Future<void> newLine(int line) async {
    Map<String, dynamic> arguments = <String, dynamic>{"line": line};
    await _channel.invokeMethod('NEW_LINE', arguments);
  }

  static Future<void> init() async {
    await _channel.invokeMethod('INIT');
  }
}
